package behavioralPattern.chain_of_responsibility.example03;

import behavioralPattern.chain_of_responsibility.example02.AuthService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Client {
    public static void main(String[] args) throws ParseException {
        // 定义责任链
        Auth_3 auth3 = new Auth_3("1003", "33");
        Auth_2 auth2 = new Auth_2("1002", "22");
        Auth_1 auth1 = new Auth_1("1001", "11");
        auth3.appendNext(auth2);
        auth2.appendNext(auth1);

        // 申请时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = format.parse("2022-11-18");

        // 三级审批
        System.out.println("==================================");
        System.out.println(auth3.doAuth("1003","989826",date).getInfo());
        AuthService.auth("1003","989826");
        System.out.println("==================================");
        System.out.println(auth3.doAuth("1003","989826",date).getInfo());
        AuthService.auth("1002","989826");
        System.out.println("==================================");
        System.out.println(auth3.doAuth("1003","989826",date).getInfo());
        AuthService.auth("1001","989826");
        System.out.println("==================================");
        System.out.println(auth3.doAuth("1003","989826",date).getInfo());


    }
}
